CREATE table account(
id BIGINT PRIMARY KEY auto_increment,
name VARCHAR(20),
balance DECIMAL(6,2)
);
BEGIN;
SELECT * from account;
COMMIT;
insert into account VALUES(null,'maybe',9999.00);
-- 开启事务
BEGIN;
SELECT * from account;
insert into account VALUES(null,'02',9999.00);
-- 回滚事务
ROLLBACK;
SELECT * from account;
insert into account VALUES(null,'02',9999.00);
insert into account VALUES(null,'03',9999.00);
-- 开启事务
begin;
insert into account VALUES(null,'04',9999.00);
-- 设置回滚点
SAVEPOINT savepoint1;
-- 回到到回滚点1
-- 且执行完ROLLBACK to savepoint1 事务未结束，要执行ROLLBACK事务才结束
ROLLBACK to savepoint1;
SELECT * from account;
ROLLBACK;

